--- usbctl.c.orig	Mon Feb 25 01:50:55 2002
+++ usbctl.c	Tue Apr 16 22:42:31 2013
@@ -62,6 +62,7 @@
 #endif
 
 #define NSTRINGS
+#define STRINGLANG
 
 int num = 0;
 
@@ -80,17 +81,43 @@ getstring(int si, char *s)
 	int r, i, n;
 	u_int16_t c;
 	usb_string_descriptor_t us;
+	int lang = 0;
 
 	if (si == 0 || num) {
 		*s = 0;
 		return;
 	}
+
+#ifdef STRINGLANG
 	req.ucr_addr = usbaddr;
 	req.ucr_request.bmRequestType = UT_READ_DEVICE;
 	req.ucr_request.bRequest = UR_GET_DESCRIPTOR;
 	req.ucr_data = &us;
-	USETW2(req.ucr_request.wValue, UDESC_STRING, si);
+	USETW2(req.ucr_request.wValue, UDESC_STRING, 0);
 	USETW(req.ucr_request.wIndex, 0);
+	USETW(req.ucr_request.wLength, sizeof(usb_string_descriptor_t));
+	req.ucr_flags = USBD_SHORT_XFER_OK;
+	r = ioctl(usbf, USB_REQUEST, &req);
+	if (r < 0) {
+		fprintf(stderr, "get lang tbl failed (error=%d)\n", errno);
+		*s = 0;
+		return;
+	}
+	if (req.ucr_actlen > 0 && us.bLength >= 4) {
+		lang = UGETW(us.bString[0]);
+#if 0
+		printf("getstring: %d langs, using %d\n",
+		       (us.bLength - 2) / 2, lang);
+#endif
+	}
+#endif
+
+	req.ucr_addr = usbaddr;
+	req.ucr_request.bmRequestType = UT_READ_DEVICE;
+	req.ucr_request.bRequest = UR_GET_DESCRIPTOR;
+	req.ucr_data = &us;
+	USETW2(req.ucr_request.wValue, UDESC_STRING, si);
+	USETW(req.ucr_request.wIndex, lang);
 #ifdef NSTRINGS
 	USETW(req.ucr_request.wLength, sizeof(usb_string_descriptor_t));
 	req.ucr_flags = USBD_SHORT_XFER_OK;
@@ -309,7 +336,7 @@ bPwrOn2PwrGood=%d bHubContrCurrent=%d DeviceRemovable=
 }
 
 void
-prhidd(usb_hid_descriptor_t *d)
+prhidd(struct usb_hid_descriptor *d)
 {
 	int i;
 
@@ -384,7 +411,7 @@ struct usb_cdc_union_descriptor {
 };
 
 void
-prcdcd(usb_descriptor_t *ud)
+prcdcd(struct usb_cdc_header_descriptor *ud)
 {
 	if (ud->bDescriptorType != UDESC_CS_INTERFACE)
 		printf("prcdcd: strange bDescriptorType=%d\n", 
@@ -630,7 +657,7 @@ gethubdesc(int f, usb_hub_descriptor_t *d, int addr)
 	req.ucr_addr = addr;
 	req.ucr_request.bmRequestType = UT_READ_CLASS_DEVICE;
 	req.ucr_request.bRequest = UR_GET_DESCRIPTOR;
-	USETW(req.ucr_request.wValue, 0);
+	USETW2(req.ucr_request.wValue, UDESC_HUB, 0);
 	USETW(req.ucr_request.wIndex, 0);
 	USETW(req.ucr_request.wLength, USB_HUB_DESCRIPTOR_SIZE);
 	req.ucr_data = d;
@@ -689,7 +716,7 @@ getconfigdesc(int f, int i, usb_config_descriptor_t *d
 }
 
 void
-gethiddesc(int f, int i, usb_hid_descriptor_t *d, int size, int addr)
+gethiddesc(int f, int i, struct usb_hid_descriptor *d, int size, int addr)
 {
 	struct usb_ctl_request req;
 	int r;
@@ -1147,7 +1174,7 @@ prdesc(void *p, int *class, int *subclass, int *iface,
 #endif
 	case UDESC_CS_DEVICE:
 		if (*class == UICLASS_HID) {
-			usb_hid_descriptor_t *hid = p;
+			struct usb_hid_descriptor *hid = p;
 			int k;
 			
 			printf("HID descriptor:\n");
@@ -1243,8 +1270,8 @@ prdesc(void *p, int *class, int *subclass, int *iface,
 	default:
 	def:
 		printf("Unknown descriptor (class %d/%d):\n", *class, *subclass);
-		printf("bLength=%d bDescriptorType=%d bDescriptorSubtype=%d ...\n", d->bLength, 
-		       d->bDescriptorType, d->bDescriptorSubtype
+		printf("bLength=%d bDescriptorType=%d ...\n", d->bLength, 
+		       d->bDescriptorType
 		       );
 		break;
 	}
@@ -1321,6 +1348,7 @@ main(int argc, char **argv)
 
 	if (!doaddr)
 		prunits(f);
+#ifndef __OpenBSD__
 	if (!nodisc) {
 		r = ioctl(f, USB_DISCOVER);
 		if (r < 0)
@@ -1329,6 +1357,7 @@ main(int argc, char **argv)
 		if (disconly)
 			exit(0);
 	}
+#endif
 
 	for(addr = 0; addr < USB_MAX_DEVICES; addr++) {
 		if (doaddr != -1 && addr != doaddr)
